'use strict';
// 实例化数据库的操作
const db = uniCloud.database();
// 创建数据库的连接
const connect = db.collection("news");
// 查询数据的工具
const dbCmd = db.command
// 返回的结果内容
let res = null;
exports.main = async (e, context) => {
	switch (e.methods) {
		case "get":
			res = await connect.orderBy("id", "asc").get();
			break;
		case "clickNum":
			res = await connect.doc(e.id).update({
				click: e.num
			});
			break;
		default:
			break;
	};
	return res;
};
